//
// Created by liu on 2019/10/9.
//

#ifndef _MODIFIED_H
#define _MODIFIED_H

# include <iostream>
# include <string>

// 抽象的手机类
class phone{
public:
    phone(){}
    virtual ~phone(){}
    virtual void showDecorate() {}
};

// 具体的手机类a
class iphone : public phone{
private:
    std::string name;
public:
    iphone(const std::string& str)
        :name(str)
    {}

    ~iphone(){}

    void showDecorate() {
        std::cout<<name<<"的装饰"<<std::endl;
    }
};

// 抽象的装饰类
class Decorate : public phone{
private:
    phone* p_phone;
public:
    Decorate(phone* pho)
        :p_phone(pho)
    {}

    virtual void showDecorate()
    {
        p_phone->showDecorate();
    }
};

// 具体的装饰类a
class DecorateA : public Decorate{
private:
    void AddDecorate(){
        std::cout<<"增加挂件"<<std::endl;
    }

public:
    DecorateA(phone* pho)
        :Decorate(pho)
    {}

    void showDecorate()
    {
        Decorate::showDecorate();
        AddDecorate();
    }
};

// 具体的装饰类b
class DecorateB : public Decorate{
private:
    void AddDecorate(){
        std::cout<<"屏幕贴膜"<<std::endl;
    }

public:
    DecorateB(phone* pho)
            :Decorate(pho)
    {}

    void showDecorate()
    {
        Decorate::showDecorate();
        AddDecorate();
    }
};

#endif //修饰模式_MODIFIED_H
